package 异常;

public class GirlFried {
    private String name;
    private  int age;

    public GirlFried() {
    }

    public GirlFried(String name, int age) {
        this.name = name;
        this.age = age;
    }

    /**
     * 获取
     * @return name
     */
    public String getName() {
        return name;
    }

    /**
     * 设置
     * @param name
     */
    public void setName(String name) {
        //获取name的长度
        int len = name.length();
        if (len<=3||len>=10){
            throw new NameFortException(name+"格式错误："+"长度限制在3-10");
        }
        this.name = name;
    }

    /**
     * 获取
     * @return age
     */
    public int getAge() {
        return age;
    }

    /**
     * 设置
     * @param age
     */
    public void setAge(int age) {
        if (age<18||age>=40){
            throw new AgeOutBoundException(age+"超出范围");
        }
        this.age = age;
    }

    public String toString() {
        return "GirlFried{name = " + name + ", age = " + age + "}";
    }
}
